package org.ediba.siri.core;

public enum Filter {
	
	ID("id"),
	ID_MIN("id"),
	ID_MAX("id"),
	ADDRESS("address"),
	BIRTHDATE("birthDate"),
	BIRTHDATE_MIN("birthDate"),
	BIRTHDATE_MAX("birthDate"),
	DATE("date"),
	DATE_MIN("date"),
	DATE_MAX("date"),
	DESCRIPTION("description"),
	EMAIL("email"),
	GENDER("gender"),
	FIRSTNAME("firstName"),
	LASTNAME("lastName"),
	LOCKING("locking"),
	MODELB_ID("id.idModelB"),
	NAME("name"),
	NUMBER("number"),
	NUMBERSTR("numberStr"),
	NUMBER_MIN("number"),
	NUMBER_MAX("number"),
	PENDING("pending"),
	WORD("word"),
	//From now on, collections properties supported, see int ordinalFirstCollection;
	ACTIONREQUEST_USER("actionrequest.user"),
	ACTIONGRANT("actiongrant"),
	ACTIONREJECT("actionreject"),
	ACTIONUSED("actionused"),
	ACTIONUNUSED("actionunused"),
	ALBUM("imagealbum"),
	IMAGE("image"),
	IMAGE_LOCKEDSEARCH("lockedSearch"),
	IMAGE_LOCKEDDOWNLOAD("lockedDownload"),
	IMAGE_CATALOGGED("catalogged"),
	IMAGE_TAGGED("tagged"),
	IMAGE_BACKUP("imagebackup"),
	IMAGE_IMAGEPROVIDER("imageprovider"),
	IMAGEKEYWORD("imagekeyword"),
	IMAGEKEYWORDA("imagekeywordForIdImageKeywordA"),
	PUBLICATIONCOUNTRY("publicationcountry"),
	PUBLICATIONCOUNTRY_MESSAGE("message"),
	PUBLICATIONNUMBER("publicationnumber"),
	PUBLICATIONNUMBER_DESCRIPTION("description"),
	TIMESTAMP("timestamp"),
	TIMESTAMP_MIN("timestamp"),
	TIMESTAMP_MAX("timestamp"),
	MODEL("model"),
	MODELFEATURE("modelfeature"),
	MODELPHONE("modelphone"),
	PUBLICATION("publication"),
	PUBLICATION_NAME("name"),
	REQUEST("request"),
	REQUESTS("request"),
	REQUEST_TYPE("type"),
	REQUEST_DESCRIPTION("description"),
	USER("user"),
	USERGROUP("usergroup"),
	MODELSCHOOL("modelschool"),
	TURN("turn");
	
	int ordinalFirstCollection = 24; // Filter.ACTIONREQUEST_USER ordinal value, change if necessary.
	String value;
	
	Filter(){this.value = null;}
	Filter(String value){this.value = value;}

	public String getProperty(){
		return this.value;
	}
	
	public String getPropertyId(){
		if (this.ordinal() >= this.ordinalFirstCollection)
			return this.value + ".id";
		else
			throw new IllegalArgumentException("Filter misuse") ;
	}
	
	public String getPropertySearch(){
		if (this.ordinal() >= this.ordinalFirstCollection){
			if (this.equals(MODELFEATURE))
				return this.value + ".feature";
			else if (this.equals(MODELPHONE))
				return this.value + ".number";
			else if (this.equals(IMAGEKEYWORD) || this.equals(IMAGEKEYWORDA))
				return this.value + ".word";
			else
				return this.value + ".id";
		}
		else
			throw new IllegalArgumentException("Filter misuse") ;
	}
	
	public String getCollection(){
		if (this.ordinal() >= this.ordinalFirstCollection){
			if (this == Filter.IMAGEKEYWORDA)
				return "imagekeywordsForIdImageKeywordA";
			else
				return this.value + "s";
		}
		else
			throw new IllegalArgumentException("Filter misuse") ;
	}
	
	
}
